package com.niit.main;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;

import com.niit.entity.Student;
import com.niit.util.MybatisUtil;

/**
 ** 根据班级名称和性别查询班级学生列表2-调用SqlSession的selectList()或selectOne()实现查询操作
 *
 * @author hanliang
 */
public class Test08_getStudentsByBatchAndGender2 {

    public static void main(String[] args) {

        List<Student> list = null;

        Map<String,Object> map=new HashMap<>();
        //添加键值对的时候，键是参数名，值是参数值
        //参数名可以自己随便起，尽量有意义
        map.put("a","22软件外包02班");
        map.put("b", "女");

        try (SqlSession session = MybatisUtil.openSession()) {
        	//如果调用selectList()执行查询，将Map集合作为第二个参数传入即可
        	list=session.selectList(
        			"getStudentListByBatchAndGender2",
        			map);
        }

		System.out.println("-------------------------------------------------------------------------------------------");
		System.out.println("学号\t\t姓名\t\t密码\t\t性别\t班级");
		System.out.println("-------------------------------------------------------------------------------------------");

        for (Student s : list) {
            System.out.println(s);
        }
    }
}
